#include "bga/graphics/CubeDrawable.h"
#include <GL/glew.h>
#include <iostream>

using namespace std;

namespace bga
{


float CubeDrawable::vertex[8*3] = {-0.5f, -0.5f, -0.5f,
                             0.5f, -0.5f, -0.5f,
                             0.5f, -0.5f, 0.5f,
                             -0.5f, -0.5f, 0.5f,
                             -0.5f, 0.5f, -0.5f,
                             0.5f, 0.5f, -0.5f,
                             0.5f, 0.5f, 0.5f,
                             -0.5f, 0.5f, 0.5f};

float CubeDrawable::color[8*3] = {1.f, 0, 0,
                             0, 1.f, 0,
                             0, 0, 1.f,
                             1.f, 1.f, 0,
                             1.f, 0, 1.f,
                             0, 1.f, 1.f,
                             1.f, 1.f, 1.f,
                             0, 0, 0};

float CubeDrawable::texCoord[8*2] = {0.f, 0,
                             1, 0.f,
                             1, 1,
                             0.f, 1.f,
                             0.f, 0,
                             1, 0.f,
                             1.f, 1.f,
                             0, 1};

unsigned short CubeDrawable::index[24] = {0, 3, 2, 1,
                             4, 5, 6, 7,
                             1, 2, 6, 5,
                             0, 4, 7, 3,
                             0, 1, 5, 4,
                             2, 3, 7, 6};


CubeDrawable::CubeDrawable(float width, float height, float depth) : Drawable(), width(width), height(height), depth(depth)
{
    this->setVertexArray(CubeDrawable::vertex, 8 * 3);
    //this->setColorsArray(CubeDrawable::color, 8 * 3);
    this->setTexCoordArray(CubeDrawable::texCoord, 8 * 3);
    this->setIndexArray(CubeDrawable::index, 24);
    this->primitive = GL_QUADS;
}

CubeDrawable::~CubeDrawable()
{
}

}
